using GCommon;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIManager : MonoBehaviour
{
    public static UIManager Instance;
    //public UIMenu mUIMenu;
    [SerializeField] GameObject mYPrefab;
    float ydelta; 

    private void Awake()
    {
        Instance = this;
    }

    // Start is called before the first frame update
    void Start()
    {

    }

    public void SetData(List<CSVBaseData> list, int max_len, float lowest, float highest)
    {
        int len = Mathf.Min(list.Count, max_len);
        ydelta = (highest - lowest) / (len - 1);

        for (int i = 0; i < Mathf.Min(list.Count, max_len); i++)
        {
            var go1 = GameObject.Instantiate(mYPrefab, mYPrefab.transform.parent);
            go1.SetActive(true);
            (go1.transform as RectTransform).anchoredPosition = new Vector2(0, 80 * (i + 1));
            go1.GetComponentInChildren<Text>().text = Mathf.RoundToInt(lowest + ydelta * i).ToString();
            go1.GetComponentInChildren<Text>().color = Color.black;
        }
    }
}
